<?php include $this->getViewFile('/common/Head'); ?>
<body class="J_scroll_fixed">
  <div class="wrap J_check_wrap">
     <?php include $this->getViewFile('/common/Nav') ?>

     <!-- 表单 -->
      <?php $objForm = $this->beginWidget('CActiveFormTabel', array('id' => 'SubmitForm', 'htmlOptions' => array('class' => 'J_ajaxForm')) ); ?>

       <div class="h_a">基本属性</div>

       <div class="table_full">
         <table width="100%" class="table_form contentWrap">
              <tbody>
                <?php echo $objForm->textFieldTable($data, 'title', array('class' => 'input length_6'), array('th' => array('width' => 100))); ?>
                <?php echo $objForm->textAreaTable($data, 'content', array('class' => 'input length_6', 'style' => 'height:100px')); ?>
                <?php 
                  if(ACTION_NAME == 'edit' && $data->img1){
                    $Url = ConfigModel::model()->getConfig('sitefileurl');
                    $Url .= $data->img1;
                    $str = "<a href='javascript:preview(\"{$Url}\")'>预览</a>";
                    echo $objForm->fileFieldTable($data, 'img1', array('name' => 'img1'), array('htmlOptions' => array('td' => $str))); 
                  }else{
                    echo $objForm->fileFieldTable($data, 'img1',array('name' => 'img1')); 
                  }                
                ?>
                <?php 
                  if(ACTION_NAME == 'edit' && $data->img2){
                    $Url = ConfigModel::model()->getConfig('sitefileurl');
                    $Url .= $data->img2;
                    $str = "<a href='javascript:preview(\"{$Url}\")'>预览</a>";
                    echo $objForm->fileFieldTable($data, 'img2', array('name' => 'img2'), array('htmlOptions' => array('td' => $str))); 
                  }else{
                    echo $objForm->fileFieldTable($data, 'img2',array('name' => 'img2')); 
                  }                
                ?>
                <?php 
                  if(ACTION_NAME == 'edit' && $data->img3){
                    $Url = ConfigModel::model()->getConfig('sitefileurl');
                    $Url .= $data->img3;
                    $str = "<a href='javascript:preview(\"{$Url}\")'>预览</a>";
                    echo $objForm->fileFieldTable($data, 'img3', array('name' => 'img3'), array('htmlOptions' => array('td' => $str))); 
                  }else{
                    echo $objForm->fileFieldTable($data, 'img3',array('name' => 'img3')); 
                  }                
                ?>
                <div></div>
              </tbody>
         </table>
       </div>


       <!-- 确定按钮 -->
       <div class="btn_wrap">
          <div class="btn_wrap_pd">
            <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">确认</button>
          </div>
       </div>

      <?php $this->endWidget(); ?>
  </div>

<script src="<?php echo $staticUrl; ?>statics/js/common.js"></script>
<script src="<?php echo $staticUrl; ?>statics/js/content_addtop.js?v"></script>
<script type="text/javascript">
//附件预览
function preview(filepath) {
    if (IsImg(filepath)) {
        Wind.use('artDialog', 'imgready', function () {
            imgReady(filepath, function () {
                var width = 0,
                    maxWidth = 500,
                    maxHeight = 500,
                    height = 0;
                var hRatio;
                var wRatio;
                var Ratio = 1;
                var w = this.height;
                var h = this.width;
                wRatio = 500 / this.height;
                hRatio = 500 / this.width;

                if (maxWidth == 0) { //
                    if (hRatio < 1) Ratio = hRatio;
                } else if (maxHeight == 0) {
                    if (wRatio < 1) Ratio = wRatio;
                } else if (wRatio < 1 || hRatio < 1) {
                    Ratio = (wRatio <= hRatio ? wRatio : hRatio);
                }
                if (Ratio < 1) {
                    w = w * Ratio;
                    h = h * Ratio;
                }
                width = h;
                height = w;

                art.dialog({
                    title: '预览',
                    fixed: true,
                    width: width,
                    height: height,
                    id: "image_priview",
                    lock: true,
                    background: "#CCCCCC",
                    opacity: 0,
                    content: '<img src="' + filepath + '"  width="' + width + '" height="' + height + '" />'
                });

            });
        });
    } else {
        Wind.use('artDialog', function () {
            art.dialog({
                title: '预览',
                padding: 0,
                width: 230,
                height: 150,
                content: '<a href="' + filepath + '" target="_blank"><img src="<?php echo $staticUrl; ?>statics/images/icon/down.gif">单击打开</a>',
                lock: true
            });
        });
    }
}
</script>

</body>
</html>